#!/usr/bin/env bash

RUNDIR=$(dirname $0)

server='root@dev.t.jiutiandata.com'
dir="/var/golang/x"
isRelease="$1"
if [ "$isRelease" == "true" ]; then
  dir="/data/online/iot"
  server='root@online.bidevice.com'
fi

app_name='kafka-delay'

`cd ${RUNDIR}/ && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $app_name.exe`

scp ${RUNDIR}/${app_name}.exe ${server}:$dir/${app_name}.exe
ssh ${server} "bash $dir/install.sh '$app_name'"

rm ${RUNDIR}/${app_name}.exe
